﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SoftwareConsulting.BI11.Studio.Core.Project.Metadata;
using SoftwareConsulting.BI11.Studio.InternalServices;

namespace SoftwareConsulting.BI11.Studio.UI.ProjectExplorer.Indicators
{
    /// <summary>
    /// Класс диалога выбора типа создаваемого показателя
    /// </summary>
    public partial class SetIndicatorTypeDialog : RestorableForm
    {
        private IndicatorType _type;

        public IndicatorType Type
        {
            get
            {
                return _type;
            }
        }
        
        /// <summary>
        /// Применяет изменения и закрывает диалог
        /// </summary>
        private void ApplyAndClose()
        {
            while (true)
            {
                if (StringCategorialRadio.Checked)
                {
                    _type = IndicatorType.CategorialString;
                    break;
                }
                if (StringOrderedRadio.Checked)
                {
                    _type = IndicatorType.OrderedString;
                    break;
                }
                if (IntegerRadio.Checked)
                {
                    _type = IndicatorType.Integer;
                    break;
                }
                if (FloatRadio.Checked)
                {
                    _type = IndicatorType.Float;
                    break;
                }
                if (DateTimeRadio.Checked)
                {
                    _type = IndicatorType.DateTime;
                    break;
                }        
                break;
            }
            DialogResult = DialogResult.OK;
            Close();
        }

        public SetIndicatorTypeDialog()
        {
            InitializeComponent();
        }

        private void OKButton_Click(object sender, EventArgs e)
        {
            ApplyAndClose();
        }
    }
}
